package com.cy.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cy.entity.LoginTicket;
import com.cy.mapper.LoginTicketMapper;
import com.cy.service.LoginTicketService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cy.util.RedisKeyUtil;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cy
 * @since 2021-11-08
 */
@Service
public class LoginTicketServiceImpl extends ServiceImpl<LoginTicketMapper, LoginTicket> implements LoginTicketService {
    @Resource
    private RedisTemplate redisTemplate;

    @Override
    public LoginTicket findLoginTicket(String ticket) {
        if(StrUtil.isNotBlank(ticket)){
            String redisKey = RedisKeyUtil.getTicketKey(ticket);
            return (LoginTicket) redisTemplate.opsForValue().get(redisKey);
        }
        return null;
    }
}
